﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameHallPanel : EventManager {
    public Text Titext;
    public Button JoinRoom;
    public Button CreateRoom;
    public Button Help, HelpRet;
    public InputField RoomID;
    public override void InformationSetting()
    {
        
    }
    private void Awake()
    {
        Titext.text = GameData.GetInstance().announcement;
        BindingSource[0].GetComponent<Button>().onClick.AddListener(delegate
        {
            FaXianBtnClick();
        });
        BindingSource[1].GetComponent<Button>().onClick.AddListener(delegate
        {
            MyClub();
            MessageManager.GetInstance().SendMsg768();
            Des();
        });
        BindingSource[3].GetComponent<Button>().onClick.AddListener(delegate
        {
            ZhanJiBtnClick();
        });
        BindingSource[4].GetComponent<Button>().onClick.AddListener(delegate
        {
            GetMe();
            Des();
        });
        Help.onClick.AddListener(BZ);
        HelpRet.onClick.AddListener(BzRet);
    }
    /// <summary>
    /// 删除本面板
    /// </summary>
    void Des() {
        Destroy(this.gameObject);
    }
    void Start()
    {
        AddListenerToButton(CreateRoom, CreatRoomBtnClick);
        AddListenerToButton(JoinRoom, JoinRoomBtnClick);
    }
    /// <summary>
    /// 展示发现面板
    /// </summary>
    void FaXianBtnClick()
    {
        MessageManager.GetInstance().Send7140();
    }

    void ZhanJiBtnClick()
    {
        MessageManager.GetInstance().Send7131(0, GameData.GetInstance().userID);
     }

    void CreatRoomBtnClick()
    {
        //Des();
        UIManager.ChangeUI(UIManager.PageState.CreateRoomPage, (GameObject obj) =>
        {
            obj.GetComponent<CreateRoomPage>().InformationSetting();
            CreateRoomController.GetInstance().CreateRoomType = "0";
            obj.GetComponent<CreateRoomPage>().ClubOrLianMengID = 0.ToString();
        });
    }

    void JoinRoomBtnClick()
    {
        if (RoomID.text!=""&& RoomID.text != null)
        {
            if (RoomID.text.Length == 6)
            {
                MessageManager.GetInstance().SendMsg76(RoomID.text);
                RoomID.text = null;
            }
            else
            {
                TooL.ShowNoticePage("请输入正确的房间号！");
            }
        }
    }
    void MyClub()
    {
        UIManager.ChangeUI(UIManager.PageState.Club, (GameObject obj) =>
        {
            obj.GetComponent<MyClubbPanel>().InformationSetting();
        });
    }
    void GetMe() {
        UIManager.ChangeUI(UIManager.PageState.GetMe, (GameObject obj) =>
        {
            obj.GetComponent<GetMePanel>().InformationSetting();
        });
    }
    void BZ() {
        BindingSource[5].SetActive(true);
    }
    void BzRet()
    {
        BindingSource[5].SetActive(false);
    }
}
